package provatable;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the "GROUP" database table.
 * 
 */
@Entity
@Table(name="\"GROUP\"")
@NamedQuery(name="Group.findAll", query="SELECT g FROM Group g")
public class Group implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private long oid;

	private String descrizione;

	private String groupname;

	//bi-directional many-to-one association to Module
	@ManyToOne
	private Module module;

	//bi-directional many-to-many association to Module
	@ManyToMany
	@JoinTable(
		name="GROUP_MODULE"
		, joinColumns={
			@JoinColumn(name="GROUP_OID")
			}
		, inverseJoinColumns={
			@JoinColumn(name="MODULE_OID")
			}
		)
	private List<Module> modules;

	//bi-directional many-to-one association to User
	@OneToMany(mappedBy="group")
	private List<User> users1;

	//bi-directional many-to-many association to User
	@ManyToMany(mappedBy="groups")
	private List<User> users2;

	public Group() {
	}

	public long getOid() {
		return this.oid;
	}

	public void setOid(long oid) {
		this.oid = oid;
	}

	public String getDescrizione() {
		return this.descrizione;
	}

	public void setDescrizione(String descrizione) {
		this.descrizione = descrizione;
	}

	public String getGroupname() {
		return this.groupname;
	}

	public void setGroupname(String groupname) {
		this.groupname = groupname;
	}

	public Module getModule() {
		return this.module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public List<Module> getModules() {
		return this.modules;
	}

	public void setModules(List<Module> modules) {
		this.modules = modules;
	}

	public List<User> getUsers1() {
		return this.users1;
	}

	public void setUsers1(List<User> users1) {
		this.users1 = users1;
	}

	public User addUsers1(User users1) {
		getUsers1().add(users1);
		users1.setGroup(this);

		return users1;
	}

	public User removeUsers1(User users1) {
		getUsers1().remove(users1);
		users1.setGroup(null);

		return users1;
	}

	public List<User> getUsers2() {
		return this.users2;
	}

	public void setUsers2(List<User> users2) {
		this.users2 = users2;
	}

}